//===----------------------------------------------------------------------===//
//
// This source file is part of the Soto for AWS open source project
//
// Copyright (c) 2017-2024 the Soto project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Soto project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//

// THIS FILE IS AUTOMATICALLY GENERATED by https://github.com/soto-project/soto-codegenerator.
// DO NOT EDIT.

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
@_exported import SotoCore

/// Service object for interacting with AWS QLDBSession service.
///
/// The transactional data APIs for Amazon QLDB  Instead of interacting directly with this API, we recommend using the QLDB driver or the QLDB shell to execute data transactions on a ledger.   If you are working with an AWS SDK, use the QLDB driver. The driver provides a high-level abstraction layer above this QLDB Session data plane and manages SendCommand API calls for you. For information and a list of supported programming languages, see Getting started with the driver in the Amazon QLDB Developer Guide.   If you are working with the AWS Command Line Interface (AWS CLI), use the QLDB shell. The shell is a command line interface that uses the QLDB driver to interact with a ledger. For information, see Accessing Amazon QLDB using the QLDB shell.
public struct QLDBSession: AWSService {
    // MARK: Member variables

    /// Client used for communication with AWS
    public let client: AWSClient
    /// Service configuration
    public let config: AWSServiceConfig

    // MARK: Initialization

    /// Initialize the QLDBSession client
    /// - parameters:
    ///     - client: AWSClient used to process requests
    ///     - region: Region of server you want to communicate with. This will override the partition parameter.
    ///     - partition: AWS partition where service resides, standard (.aws), china (.awscn), government (.awsusgov).
    ///     - endpoint: Custom endpoint URL to use instead of standard AWS servers
    ///     - middleware: Middleware chain used to edit requests before they are sent and responses before they are decoded 
    ///     - timeout: Timeout value for HTTP requests
    ///     - byteBufferAllocator: Allocator for ByteBuffers
    ///     - options: Service options
    public init(
        client: AWSClient,
        region: SotoCore.Region? = nil,
        partition: AWSPartition = .aws,
        endpoint: String? = nil,
        middleware: AWSMiddlewareProtocol? = nil,
        timeout: TimeAmount? = nil,
        byteBufferAllocator: ByteBufferAllocator = ByteBufferAllocator(),
        options: AWSServiceConfig.Options = []
    ) {
        self.client = client
        self.config = AWSServiceConfig(
            region: region,
            partition: region?.partition ?? partition,
            amzTarget: "QLDBSession",
            serviceName: "QLDBSession",
            serviceIdentifier: "session.qldb",
            signingName: "qldb",
            serviceProtocol: .json(version: "1.0"),
            apiVersion: "2019-07-11",
            endpoint: endpoint,
            variantEndpoints: Self.variantEndpoints,
            errorType: QLDBSessionErrorType.self,
            middleware: middleware,
            timeout: timeout,
            byteBufferAllocator: byteBufferAllocator,
            options: options
        )
    }




    /// FIPS and dualstack endpoints
    static var variantEndpoints: [EndpointVariantType: AWSServiceConfig.EndpointVariant] {[
        [.fips]: .init(endpoints: [
            "us-east-1": "session.qldb-fips.us-east-1.amazonaws.com",
            "us-east-2": "session.qldb-fips.us-east-2.amazonaws.com",
            "us-west-2": "session.qldb-fips.us-west-2.amazonaws.com"
        ])
    ]}

    // MARK: API Calls

    /// Sends a command to an Amazon QLDB ledger.  Instead of interacting directly with this API, we recommend using the QLDB driver or the QLDB shell to execute data transactions on a ledger.   If you are working with an AWS SDK, use the QLDB driver. The driver provides a high-level abstraction layer above this QLDB Session data plane and manages SendCommand API calls for you. For information and a list of supported programming languages, see Getting started with the driver in the Amazon QLDB Developer Guide.   If you are working with the AWS Command Line Interface (AWS CLI), use the QLDB shell. The shell is a command line interface that uses the QLDB driver to interact with a ledger. For information, see Accessing Amazon QLDB using the QLDB shell.
    @Sendable
    @inlinable
    public func sendCommand(_ input: SendCommandRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> SendCommandResult {
        try await self.client.execute(
            operation: "SendCommand", 
            path: "/", 
            httpMethod: .POST, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Sends a command to an Amazon QLDB ledger.  Instead of interacting directly with this API, we recommend using the QLDB driver or the QLDB shell to execute data transactions on a ledger.   If you are working with an AWS SDK, use the QLDB driver. The driver provides a high-level abstraction layer above this QLDB Session data plane and manages SendCommand API calls for you. For information and a list of supported programming languages, see Getting started with the driver in the Amazon QLDB Developer Guide.   If you are working with the AWS Command Line Interface (AWS CLI), use the QLDB shell. The shell is a command line interface that uses the QLDB driver to interact with a ledger. For information, see Accessing Amazon QLDB using the QLDB shell.
    ///
    /// Parameters:
    ///   - abortTransaction: Command to abort the current transaction.
    ///   - commitTransaction: Command to commit the specified transaction.
    ///   - endSession: Command to end the current session.
    ///   - executeStatement: Command to execute a statement in the specified transaction.
    ///   - fetchPage: Command to fetch a page.
    ///   - sessionToken: Specifies the session token for the current command. A session token is constant throughout the life of the session. To obtain a session token, run the StartSession command. This SessionToken is required for every subsequent command that is issued during the current session.
    ///   - startSession: Command to start a new session. A session token is obtained as part of the response.
    ///   - startTransaction: Command to start a new transaction.
    ///   - logger: Logger use during operation
    @inlinable
    public func sendCommand(
        abortTransaction: AbortTransactionRequest? = nil,
        commitTransaction: CommitTransactionRequest? = nil,
        endSession: EndSessionRequest? = nil,
        executeStatement: ExecuteStatementRequest? = nil,
        fetchPage: FetchPageRequest? = nil,
        sessionToken: String? = nil,
        startSession: StartSessionRequest? = nil,
        startTransaction: StartTransactionRequest? = nil,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> SendCommandResult {
        let input = SendCommandRequest(
            abortTransaction: abortTransaction, 
            commitTransaction: commitTransaction, 
            endSession: endSession, 
            executeStatement: executeStatement, 
            fetchPage: fetchPage, 
            sessionToken: sessionToken, 
            startSession: startSession, 
            startTransaction: startTransaction
        )
        return try await self.sendCommand(input, logger: logger)
    }
}

extension QLDBSession {
    /// Initializer required by `AWSService.with(middlewares:timeout:byteBufferAllocator:options)`. You are not able to use this initializer directly as there are not public
    /// initializers for `AWSServiceConfig.Patch`. Please use `AWSService.with(middlewares:timeout:byteBufferAllocator:options)` instead.
    public init(from: QLDBSession, patch: AWSServiceConfig.Patch) {
        self.client = from.client
        self.config = from.config.with(patch: patch)
    }
}
